signal = sin(2*pi*0.055*(0:1000-1)');
Hs = dsp.SignalSource(signal,'SamplesPerFrame',100,...
    'SignalEndAction','Cyclic repetition');
figure(1);
subplot(2,1,1);
plot(0:199,signal(1:200));
grid; axis([0 200 -2 2]);
title('The information bearing signal');
nvar  = 1.0;                  % Noise variance
noise = randn(1000,1)*nvar;   % White noise
Hn = dsp.SignalSource(noise,'SamplesPerFrame',100,...
    'SignalEndAction','Cyclic repetition');
figure(1);
subplot(2,1,2);
plot(0:999,noise);
title('Noise picked up by the secondary microphone');
grid; axis([0 1000 -4 4]);
Hd = dsp.FIRFilter('Numerator',fir1(31,0.5));% Low pass FIR filter
M      = 32;                 % Filter order
delta  = 0.1;                % Initial input covariance estimate
P0     = (1/delta)*eye(M,M); % Initial setting for the P matrix
Hadapt = dsp.RLSFilter(M,'InitialInverseCovariance',P0);
Hts = dsp.TimeScope('TimeSpan',1000,'YLimits',[-2,2]);
for k = 1:10
    n = step(Hn); % Noise
    s = step(Hs);
    d = step(Hd,n) + s;
    [y,e]  = step(Hadapt,n,d);
    step(Hts,[s,e]);
end
H  = abs(freqz(Hadapt.Coefficients,1,64));
H1 = abs(freqz(Hd.Numerator,1,64));
wf = linspace(0,1,64);
figure(2);
plot(wf,H,wf,H1);
xlabel('Normalized Frequency  (\times\pi rad/sample)');
ylabel('Magnitude');
legend('Adaptive Filter Response','Required Filter Response');
grid;
axis([0 1 0 2]);